import 'package:flutter/material.dart';
import 'button_demo.dart';
import 'floating_action_button_demo.dart';
import 'container_button_demo.dart';
import 'popup_menu_button_demo.dart';

class ListViewDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView(
      children: <Widget>[
        ListItem(
          title: "FloatingActionButton",
          page: FloatingActionButtonDemo(),
        ),
        ListItem(
          title: "ButtonDemo",
          page: ButtonDemo(),
        ),
        ListItem(
          title: "ContainerButtonDemo",
          page: ContainerButtonDemo(),
        ),
        ListItem(
          title: "PopupMenuButonDemo",
          page: PopupMenuButonDemo(),
        ),
      ],
    );
  }
}

class ListItem extends StatelessWidget {
  final String title;

  final Widget page;

  ListItem({this.title, this.page});

  @override
  Widget build(BuildContext context) {
    return ListTile(
      title: Text(title),
      onTap: () {
        Navigator.of(context).push(
          MaterialPageRoute(builder: (conetext) => page),
        );
      },
    );
  }
}
